package com.zmj.sy.mom.srv.aps.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zmj.sy.mom.srv.aps.bean.entity.resource.Weekday;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseListResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.weekday.WeekdayListReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.weekday.WeekdayListResVo;
import com.zmj.sy.mom.srv.aps.mapper.WeekdayMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@RequiredArgsConstructor
@Service
public class WeekdayService {
    
    private final WeekdayMapper weekdayMapper;

    @SuppressWarnings("unchecked")
    public BaseListResVo<WeekdayListResVo> list(WeekdayListReqVo reqVo) {
        LambdaQueryWrapper<Weekday> wrapper = Wrappers.lambdaQuery();
        wrapper.between(Weekday::getShiftDay, reqVo.getStartDate(), reqVo.getEndDate());
        wrapper.orderByAsc(Weekday::getShiftDay, Weekday::getShiftSeq);
        List<Weekday> weekdays = weekdayMapper.selectList(wrapper);

        return BaseListResVo.of(weekdays, WeekdayListResVo.class);
    }
}
